package com.hua.api.core.activemq;


import com.alibaba.fastjson.JSONObject;
import com.hua.api.core.util.StringUtil;


@SuppressWarnings("all")
public class MqMessageBuilder {

    private JSONObject message;

    private JSONObject data;

    MqMessageBuilder(){
        this.message = new JSONObject();
        this.data = new JSONObject();
    }

    public static MqMessageBuilder builder(){
        MqMessageBuilder builder = new MqMessageBuilder();
        return builder;
    }

    public MqMessageBuilder target(String target){
        this.message.put("target",target);
        return this;
    }

    public MqMessageBuilder event(String event){
        this.message.put("event",event);
        return this;
    }

    public MqMessageBuilder data(JSONObject data){
        this.message.put("data",data);
        return this;
    }

    public MqMessageBuilder set(String key,Object value){
        if(!StringUtil.isEmpty(value)){
            this.data.put(key,value);
        }
        return this;
    }

    public JSONObject build(){
        this.message.put("data",this.data);
        return this.message;
    }




}
